<?php
namespace app\yunda\model;

use think\Model;
use traits\model\SoftDelete;

/**
 * 快件分类表
 * @package app\yunda\model
 */
class Category extends Model
{
    use SoftDelete;
    protected $table = 'dp_yd_category';
    protected $autoWriteTimestamp = true;

    //获取物品
    public function getGood()
    {
        $list=$this->where(['status'=>1])->field('id,name')
            ->order('sort desc,id desc')
            ->select();
        $list=collection($list)->toArray();
        return $list;
    }

    //筛选
    public static function search()
    {
        $list=self::where(['status'=>1])->column('id,name');
        return $list;
    }

    //获取某个物品
    public static function getOne($id)
    {
        $row=self::get($id);
        if(empty($row)) return '';
        return $row['name'];
    }
}
